package com.njust.controller;


import com.njust.domain.dto.ProcedureDTO;
import com.njust.domain.vo.PageQueryVO;
import com.njust.result.Result;
import com.njust.service.ProcedureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author Imak
 * @Date 2024/11/7 16:53
 * @规程
 */
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/procedure")
@Slf4j
public class ProcedureController {
    @Autowired
    private ProcedureService procedureService;

    /**
     * 查询该项目所有规程
     * @param project_id
     * @return
     */
    @GetMapping("/getPDF/{project_id}")
    public Result<PageQueryVO> getProcedure(@PathVariable int project_id){
        log.info("查询规程，项目id为：{}",project_id);
        PageQueryVO PageQueryVO=procedureService.getProcedure(project_id);
        return Result.success(PageQueryVO);
    }

    /**
     * 删除规程
     * @return
     */
    @DeleteMapping("/delete_pdf")
    public Result<String> deleteProcedure(Integer procedure_pdf_id){
        log.info("删除规程pdf,id为: {}",procedure_pdf_id);
        procedureService.deleteProcedure(procedure_pdf_id);
        return Result.success("规程pdf删除成功");
    }

    /**
     * 上传规程pdf文件
     * @param procedureDTO
     * @return
     */
    @PostMapping("/upload_pdf")
    public Result<String> uploadProcedure(@RequestBody ProcedureDTO procedureDTO){
        log.info("规程pdf上传：{}",procedureDTO);
        procedureService.uploadProcedure(procedureDTO);
        return Result.success("规程上传成功！");
    }






}
